package com.owc.domain.dto.admin;

import com.owc.common.converter.OutputConverter;
import com.owc.common.enums.StatusEnum;
import com.owc.domain.entity.TransferRecord;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @Author xiaom
 * @Date 2019/12/24 15:51
 * @Version 1.0.0
 * @Description <>
 **/
@NoArgsConstructor
@Data
public class ChainBean implements OutputConverter<ChainBean, TransferRecord> {
    private String txHash;
    private String commitTime;
    private BigDecimal rechargeAmount;
    private BigDecimal handlingFree;
    private Integer status;

    @Override
    public void customConverter(ChainBean chainBean, TransferRecord transferRecord) {
        chainBean.setTxHash(transferRecord.getTxhash());
        chainBean.setCommitTime(transferRecord.getCommittime());
        chainBean.setHandlingFree(new BigDecimal((transferRecord.getGas() == null ? "0" : transferRecord.getGas()) + ""));
        chainBean.setRechargeAmount(StatusEnum.SUCCESS.getType().equals(transferRecord.getStatus()) ? transferRecord.getTransferamount() : BigDecimal.ZERO);
    }
}